package com.mybatis.entity;

import java.util.ArrayList;
import java.util.List;
import org.apache.ibatis.session.RowBounds;

public class Page<E> extends ArrayList<E> {
    protected static final int NO_SQL_COUNT = -1;
    protected static final int SQL_COUNT = 0;
    private static final long serialVersionUID = 1;
    protected int endRow;
    protected int pageNum;
    protected int pageSize;
    protected int pages;
    private String sEcho;
    protected int startRow;
    protected long total;

    public Page(int pageSize2) {
        this(pageSize2, (int) SQL_COUNT);
    }

    public Page(int pageNum2, int pageSize2) {
        this(pageNum2, pageSize2, (int) SQL_COUNT);
    }

    /* JADX INFO: this call moved to the top of the method (can break code semantics) */
    public Page(int pageNum2, int pageSize2, boolean count) {
        this(pageNum2, pageSize2, count ? SQL_COUNT : NO_SQL_COUNT);
    }

    /* JADX INFO: super call moved to the top of the method (can break code semantics) */
    public Page(int startRow2, int pageSize2, int total2) {
        super(pageSize2 > NO_SQL_COUNT ? pageSize2 : SQL_COUNT);
        this.pageSize = pageSize2;
        this.startRow = startRow2;
        this.endRow = startRow2 + pageSize2;
    }

    /* JADX INFO: this call moved to the top of the method (can break code semantics) */
    public Page(RowBounds rowBounds, boolean count) {
        this(rowBounds, count ? SQL_COUNT : NO_SQL_COUNT);
    }

    /* JADX INFO: super call moved to the top of the method (can break code semantics) */
    public Page(RowBounds rowBounds, int total2) {
        super(rowBounds.getLimit() > NO_SQL_COUNT ? rowBounds.getLimit() : SQL_COUNT);
        this.pageSize = rowBounds.getLimit();
        this.startRow = rowBounds.getOffset();
        this.total = (long) total2;
        this.endRow = this.startRow + this.pageSize;
    }

    public List<E> getResult() {
        return this;
    }

    public int getPages() {
        return this.pages;
    }

    public void setPages(int pages2) {
        this.pages = pages2;
    }

    public int getEndRow() {
        return this.endRow;
    }

    public void setEndRow(int endRow2) {
        this.endRow = endRow2;
    }

    public int getPageNum() {
        return this.pageNum;
    }

    public void setPageNum(int pageNum2) {
        this.pageNum = pageNum2;
    }

    public int getPageSize() {
        return this.pageSize;
    }

    public void setPageSize(int pageSize2) {
        this.pageSize = pageSize2;
    }

    public int getStartRow() {
        return this.startRow;
    }

    public void setStartRow(int startRow2) {
        this.startRow = startRow2;
    }

    public long getTotal() {
        return this.total;
    }

    public void setTotal(long total2) {
        this.total = total2;
        if (this.pageSize > 0) {
            this.pages = (int) (((long) (total2 % ((long) this.pageSize) == 0 ? SQL_COUNT : 1)) + (total2 / ((long) this.pageSize)));
        } else {
            this.pages = (int) total2;
        }
    }

    public boolean isCount() {
        return this.total > -1;
    }

    public String toString() {
        return "Page{pageNum=" + this.pageNum + ", pageSize=" + this.pageSize + ", startRow=" + this.startRow + ", endRow=" + this.endRow + ", total=" + this.total + ", pages=" + this.pages + '}';
    }

    public long getITotalRecords() {
        return getTotal();
    }

    public long getITotalDisplayRecords() {
        return getTotal();
    }

    public List<E> getAaData() {
        return this;
    }

    public String getsEcho() {
        return this.sEcho;
    }

    public void setsEcho(String sEcho2) {
        this.sEcho = sEcho2;
    }

    public int getLength() {
        return size();
    }
}
